<template>
  <div class="my">
      <div class="myinfo">
          <img :src="avator" />
          <div>
              <p>{{userInfo.nickName}}</p>
              <p v-if="userInfo.nickName">微信用户</p>
              <p v-else>点击登录</p>
          </div>
      </div>
      <div class="iconList">
          <div v-for="(item,index) in listData" :key="index">
              <img :src="item.icon" />
              <span>{{item.title}}</span>
          </div>
      </div>
  </div>
</template>

<script>
import { login, toLogin } from '../../utils'
export default {
    data() {
        return {
            listData: [
                {title: "我的订单", icon: require('../../../static/images/order.png')},
                {title: "优惠券", icon: require('../../../static/images/discount.png')},
                {title: "我的足迹", icon: require('../../../static/images/footprint.png')},
                {title: "我的收藏", icon: require('../../../static/images/collect.png')},
                {title: "地址管理", icon: require('../../../static/images/address.png')},
                {title: "联系客服", icon: require('../../../static/images/service.png')},
                {title: "帮助中心", icon: require('../../../static/images/help.png')},
                {title: "意见反馈", icon: require('../../../static/images/opinion.png')},
            ],
            avator: '',   // 用户头像
            userInfo: {}
        }
    },
    onShow() {
        // 判断用户是否授权
        if(login()) {
            this.userInfo = login()
            // console.log(this.userInfo)
            this.avator = this.userInfo.avatarUrl
        }
    }
}
</script>

<style scoped>
@import './style.css';
</style>